package com.it2297.model;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.*;

import com.it2297.main.App;
public class Category {

	private String categoryCode;
	private String prodDesc;
	
	
	public String getCategoryCode() {
		return categoryCode;
	}
	public void setCategory(String categoryCode) {
		this.categoryCode = categoryCode;
	}
	public String getProdDesc() {
		return prodDesc;
	}
	public void setProdDesc(String prodDesc) {
		this.prodDesc = prodDesc;
	}
	
	
	public static Category getCategory(String categoryCode){
		
		Category category = new Category();
		
		try {
			App.mySqlConnection.open();
			
			ResultSet resultSet = App.mySqlConnection.executeQuery("SELECT * FROM americano.category WHERE  category = '" +categoryCode+"'");
			
			while(resultSet.next()){
				category.setCategory(resultSet.getString("category"));
				category.setProdDesc(resultSet.getString("description"));
			}
		} catch (SQLException e) {
			e.printStackTrace();
		}finally{
			App.mySqlConnection.close();
		}
		
		return category;
	}
}
